# from base64 import b64decode
# a = "eyJzb25nSUQiOjQyOTI0MDQsInNvbmdUeXBlIjoieWMiLCJzb25nTmFtZSI6Ilx1NjdmM1x1NGVhZFx1OGJiMCIsImZpbGUiOiIiLCJzaW5nZXJJRCI6MTA5MDEyMCwic2luZ2VyIjoiXHU1M2Y2XHU2ZDFiXHU2ZDFiIiwiYXZhdGFyIjoiaHR0cHM6XC9cL3dzaW5nYnNzZGwua3Vnb3UuY29tXC9jNGMxNzUyZDRmYjYwYzE5OTQ3OGI0YmE4NDA2YzdlMS5qcGciLCJjb2xsZWN0IjpmYWxzZX0="
# print(str(b64decode(a), "utf-8"))

'''
1. 不会逆向js5sing，将来希望有机会破解
2. 无奈采用selenium抓取audio标签，气死了！！！！
'''

url = "http://5sing.kugou.com/yc/4292404.html"
heards = {
    "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36"
}
from selenium.webdriver import Chrome

from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
#设置参数，无头浏览器
opt = Options()
opt.add_argument("--headless")
opt.add_argument("--disable-gpu")

web = Chrome(options=opt)

web.get(url=url)

# music_url = web.find_element(by=By.XPATH, value='/html/body/div[17]/audio/@src')
music_url = web.find_element(by=By.XPATH, value='/html/body/div[17]/audio').get_attribute("src")
# print(music_url.get_attribute("src"))
import requests
resp = requests.get(url=music_url, headers=heards)
# resp.encoding = "utf-8"
with open("./文件/ltj.mp3", mode='wb') as f:
    f.write(resp.content)